using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy_ArcherElf : Enemy
{
    public bool CanStunned { get => canStunned; }
    public Enemy_DeadState skeletonDeadState;

    public ArcherElfBattleState archerElfBattleState { get; private set; }

    [Header("----- Arrow -----")]
    [SerializeField] private GameObject arrowPrefab;
    [SerializeField] private float shootSpeed = 10;
    [SerializeField] private Transform shootTrans;
    protected override void Awake()
    {
        base.Awake();
        idleState = new(this, stateMachine, "Idle");
        moveState = new(this, stateMachine, "Move");
        attackState = new(this, stateMachine, "Attack");
        archerElfBattleState = new(this, stateMachine, "Battle");
        skeletonDeadState = new(this, stateMachine, "Dead");
        stunnedState = new(this, stateMachine, "Stunned");

        battleState = archerElfBattleState;
    }

    protected override void OnEnable()
    {
        base.OnEnable();
        stateMachine.InitMachine(idleState);
    }
    protected override void OnDisable()
    {
        base.OnDisable();
        stateMachine.ChangeState(idleState);
    }
    public override void EntityDead()
    {
        base.EntityDead();
        stateMachine.ChangeState(skeletonDeadState);
        StopSlowdownEntityCo();
    }
    //处理敌人眩晕
    public void HanderCounter()
    {
        if (CanStunned)
            stateMachine.ChangeState(stunnedState);
    }

    public override void RemoteAttack()
    {
        GameObject arrow = Instantiate(arrowPrefab, shootTrans.position, Quaternion.identity);
        arrow.GetComponent<Enemy_ArcherElfArrow>().SetupArrow(shootSpeed * facingDir, combat);
    }
}
